<?php

/*
 * CopyRight  : (C)2012-2099 HaoTeam Inc.
 * Document   : AdminUserValidate.php
 * Created on : 2021-1-29 13:53:25
 * Author     : Tiger <1192851302@qq.com>
 * Description: This is NOT a freeware, use is subject to license terms.
 *              这即使是一个免费软件,使用时也请遵守许可证条款,得到当时人书面许可.
 *              未经书面许可,不得翻版,翻版必究;版权归属 HaoTeam Inc;
 */

namespace haoteam\http\validates;

use think\Validate;

/**
 * 系统用户验证器
 * Class AdminUserValidate
 * Tiger <1192851302@qq.com> 2021-1-29 13:53:25
 */
class AdminUserValidate extends Validate {

    protected $rule = [
        'id' => 'require|number',
        'username' => 'require|chsDash|max:32',
        'password' => 'require|min:6|max:12|confirm:repassword',
        'repassword' => 'require|min:6|max:12|confirm:repassword',
        'real_name' => 'require|chs|max:6',
        'mobile' => 'require|mobile|unique:admin_user',
        'email' => 'require|email|unique:admin_user',
        'avatar' => 'url'
    ];
    protected $message = [
        'id.require' => 'ID不能为空',
        'id.number' => 'ID格式不正确',
        'username.require' => '用户名不能为空',
        'username.chsDash' => '用户名只能是汉字、字母、数字和下划线_及破折号-',
        'username.max' => '用户名最大32个字符',
        'password.require' => '密码不能为空',
        'password.min' => '密码最少要6个字符',
        'password.max' => '密码最大12字符',
        'password.confirm' => '两次密码不一致',
        'repassword.require' => '重复密码不能为空',
        'repassword.min' => '重复密码最少要6个字符',
        'repassword.max' => '重复密码最大12字符',
        'repassword.confirm' => '两次密码不一致',
        'real_name.require' => '姓名不能为空',
        'real_name.chs' => '姓名只能是汉字',
        'real_name.max' => '用户名最大6个字符',
        'mobile.require' => '手机号码不能为空',
        'mobile.mobile' => '手机号码格式不正确',
        'mobile.unique' => '手机号码已存在',
        'email.require' => '电子邮箱不能为空',
        'email.email' => '电子邮箱格式不正确',
        'email.unique' => '电子邮箱已存在',
        'avatar.url' => '头像格式不正确'
    ];
    protected $scene = [
        'create' => ['username', 'real_name', 'mobile', 'email', 'password', 'repassword'],
        'register' => ['username', 'mobile', 'password', 'repassword'],
        'update' => ['id', 'username', 'real_name', 'mobile', 'email', 'avatar'],
        'delete' => ['id'],
        'forget' => ['password', 'repassword']
    ];

}
